﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Collections.Specialized;
using System.Text;
using SCRUM.Core.BusinessObjects;
using SCRUM.Core.DAO;
using SCRUM.Core.MembershipProviders;
using System.Web.UI.WebControls;

/// <summary>
/// HierarchicalObjectDetails displays information about some Item in form of unified form.
/// Each Item has it's Superior Item in scrum hierarchy which is of SuperiorItemType
/// Enables user to:
///  * display selected Item
///  * update eddited selected Item in persistent storage
///  * create new Item in persistent storage
///  * delete selected Item from persistent storage
/// </summary>
public abstract class HierarchicalObjectDetails<Item, SuperiorItemType> : ObjectDetails<Item>
{
    /// <summary>
    /// Gets or sets the item on which operates these Details
    /// </summary>
    /// <value>The sprint.</value>
    public override Item SelectedItem
    {
        get
        {
            return selectedItem;
        }
        set
        {
            //selectedItem = value;
            //if(AvailableSuperiorItems == null) LoadAvailableSuperiorItems();
            //DisplayItem(value);

            if(AvailableSuperiorItems == null) LoadAvailableSuperiorItems();
            base.SelectedItem = value;
        }
    }

    /// <summary>
    /// Gets or sets the superior item ID of this item.
    /// </summary>
    /// <value>The superior item ID.</value>
    public int SuperiorItemID
    {
        set
        {
            this.superiorItemID = value;
        }

        get
        {
            return this.superiorItemID;
        }
    }
    private int superiorItemID = -1;

    /// <summary>
    /// Gets or sets the Project ID in which is current entity.
    /// </summary>
    /// <value>The master superior item ID.</value>
    public int ProjectID
    {
        set
        {
            this.projectID = value;
        }
        get
        {
            return this.projectID;
        }
    }
    private int projectID = -1;

    /// <summary>
    /// Gets or sets the available superior items for item handled by this HierarchicalObjectDetails
    /// </summary>
    /// <value>The available superior items.</value>
    public IList<SuperiorItemType> AvailableSuperiorItems { set; get; }

    /// <summary>
    /// Loads the available superior items.
    /// </summary>
    protected abstract void LoadAvailableSuperiorItems();
}

